# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Anthony25 <Anthony Ruhier>

_pkgname=Flask-Migrate
pkgname=python-flask-migrate
pkgver=4.0.4
pkgrel=2
pkgdesc='SQLAlchemy database migrations for Flask applications using Alembic..'
url='https://github.com/miguelgrinberg/Flask-Migrate/'
arch=('any')
license=('MIT')
depends=('python' 'python-alembic' 'python-flask' 'python-flask-sqlalchemy')
makedepends=(
  python-build
  python-installer
  python-setuptools
  python-wheel
  python-sphinx
)
checkdepends=(
  python-pytest
)
source=(https://github.com/miguelgrinberg/Flask-Migrate/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz)
sha256sums=('b739bd9ba6c60a9542eaa471964278dd9c6e7e041e05611d066b120e73e20fd0')
sha512sums=('66d7a96aafe81e94b59f3e510036dda82047c53a9bf67654ee5fe77ee30361f516a36000648f58de2743e1fa288302be76a82601a1eeae65f0acb8fd486fa9c1')

build() {
  cd ${_pkgname}-${pkgver}
  python -m build --wheel --no-isolation
  make -j1 -C docs man text SPHINXBUILD=sphinx-build
}

check() {
  cd ${_pkgname}-${pkgver}
  PYTHONPATH="${PWD}/build/lib" \
    py.test

}

package() {
  cd ${_pkgname}-${pkgver}
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -Dm 644 README.md CHANGES.md -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -Dm 644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}"
  install -Dm 644 docs/_build/text/* -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -Dm 644 docs/_build/man/flask-migrate.1 "${pkgdir}/usr/share/man/man1/${pkgname}.1"
}

# vim: ts=2 sw=2 et:
